﻿using OABackground.Infrastructure;
using System;
using System.Collections.Generic;
using System.Text;
using OABackground.Entities;

namespace OABackground.Services
{
    public class LoginSevice
    {
        private LoginRepository loginRepository = new LoginRepository();
        public bool VerifyPassword(string id, string password)
        {
            var teacher = new Teacherpassword();
            try
            {
                teacher = loginRepository.Query(id);
            }
            catch
            {
                return false;
            }
            if (teacher.Teacherpassword1 == password)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool VerifySection(string id, string type)
        {
            string sectionname = "";
            var teacherinfomation = loginRepository.QueryTeacherInformation(id);
            var section = loginRepository.QuerySection(teacherinfomation.Departmentid);
            switch (type)
            {
                case "js":
                    sectionname = "教师";
                    break;
                case "cwc":
                    sectionname = "财务处";
                    break;
                case "zjc":
                    sectionname = "政教处";
                    break;
                case "xz":
                    sectionname = "校长";
                    break;
                default:
                    break;
            }
            return section.Name == sectionname;
        }
    }
}
